package com.ruoyi.wechat.api;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wechat.domain.Activity;
import com.ruoyi.wechat.service.IActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 营地活动表Controller
 *
 * @author ruoyi

 */
@RestController
@RequestMapping("/wechatt/activity")
public class WxActivityController extends BaseController {
    @Autowired
    private IActivityService activityService;

    /**
     * 查询营地活动表列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Activity activity)
    {
        startPage();
        List<Activity> list = activityService.selectActivityList(activity);
        return getDataTable(list);
    }

    /**
     * 获取营地活动表详细信息
     */

    @GetMapping(value = "/{activityId}")
    public AjaxResult getInfo(@PathVariable("activityId") String activityId)
    {
        return success(activityService.selectActivityByActivityId(activityId));
    }
    @GetMapping(value = "/getInfoByCampId/{campId}")
    public AjaxResult getInfoByCampId(@PathVariable("campId") String campId)
    {
        return success(activityService.selectActivityBycampId(campId));
    }

    /**
     * 新增营地活动表
     */

    @Log(title = "营地活动表", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody Activity activity)
    {
        return success(activityService.insertActivity(activity));
    }

    /**
     * 修改营地活动表
     */

    @Log(title = "营地活动表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Activity activity)
    {
        return toAjax(activityService.updateActivity(activity));
    }

    /**
     * 删除营地活动表
     */

    @Log(title = "营地活动表", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{activityId}")
    public AjaxResult remove(@PathVariable String activityId)
    {
        return toAjax(activityService.deleteActivityByActivityId(activityId));
    }
}
